//
//  GQJPropertyTestController.m
//  TotalDemo
//
//  Created by gujian on 16/7/19.
//  Copyright © 2016年 gujian. All rights reserved.
//

#import "GQJPropertyTestController.h"
#import <objc/runtime.h>

OBJC_EXTERN int _objc_rootRetainCount(id);
OBJC_EXTERN void _objc_autoreleasePoolPrint();

@implementation GQJPropertyTestController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    @autoreleasepool {
        id __strong obj = [[NSObject alloc] init];
        
        _objc_autoreleasePoolPrint();
        
        id __weak weakStr = obj;
        
        NSLog(@"before use the weak variable,retainCount:%d",_objc_rootRetainCount(obj));
        
        NSLog(@"class = %@", [weakStr class]);
        
        NSLog(@"after use the weak variable, retainCount:%d",_objc_rootRetainCount(obj));
        
        _objc_autoreleasePoolPrint();
    }

    
    id __strong obj = [[NSObject alloc] init];
    id __weak o = obj;
    
    NSLog(@"1 %@",o);
    NSLog(@"2 %@",o);
    NSLog(@"3 %@",o);
    NSLog(@"4 %@",o);
    NSLog(@"5 %@",o);

//    id temp = o;
//    NSLog(@"1 %@",temp);
//    NSLog(@"2 %@",temp);
//    NSLog(@"3 %@",temp);
//    NSLog(@"4 %@",temp);
//    NSLog(@"5 %@",temp);
    
}







@end

















